cmake_minimum_required(VERSION 3.25)

set(PROJECT_LANG CXX)
if(APPLE)
    set(PROJECT_LANG ${PROJECT_LANG} OBJC OBJCXX)
endif()

project(YADAW VERSION 0.1 LANGUAGES ${PROJECT_LANG})

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(ENABLE_PRECOMPILE "Enable precompile" ON)

# Prerequisites and dependencies
find_package(Qt6 6.5 COMPONENTS Core Gui Qml Quick QuickTemplates2 LinguistTools REQUIRED)

find_package(ade CONFIG REQUIRED)
if(WIN32)
    if(DEFINED Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION)
        find_package(cppwinrt CONFIG REQUIRED)
        find_package(unofficial-sqlite3 CONFIG REQUIRED)
    endif()
elseif(APPLE)
    if(DEFINED Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION)
        find_package(unofficial-sqlite3 CONFIG REQUIRED)
    endif()
endif()
find_path(SQLITE_MODERN_CPP_INCLUDE_DIRS "sqlite_modern_cpp.h")
find_package(yaml-cpp CONFIG REQUIRED)

include_directories(${PROJECT_SOURCE_DIR}/content
                    ${PROJECT_SOURCE_DIR}/src
                    ${CLAP_SOURCE_DIR}/include # CLAP
                    ${SQLITE_MODERN_CPP_INCLUDE_DIRS}) # sqlite-modern-cpp

## VST3
set(SMTG_ADD_VSTGUI OFF)
set(SMTG_ENABLE_VST3_PLUGIN_EXAMPLES OFF)
set(SMTG_CREATE_MODULE_INFO OFF)
set(SMTG_RUN_VST_VALIDATOR OFF)
set(SMTG_ENABLE_VSTGUI_SUPPORT OFF)
set(SMTG_CREATE_PLUGIN_LINK OFF)
add_subdirectory(${VST3SDK_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)

add_subdirectory(content)

if(MSVC)
    add_compile_options(/Wall
                        /wd4820 # 'bytes' bytes padding added after construct 'member_name'
                        /wd4267 # conversion from `size_t` to `type`, possible loss of data
                        /wd4365 # conversion from 'type_1' to 'type_2', signed/unsigned mismatch
                        /wd4018 /wd4388 # signed/unsigned mismatch
                        /wd4265 # class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
                        /wd4464 # relative include path contains '..' (this warning only appears while compiling MOC files generated by Qt)
                        /wd4625 # copy constructor was implicitly defined as deleted
                        /wd4626 # assignment operator was implicitly defined as deleted
                        /wd4668 # 'xxx' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
                        /wd5026 # move constructor was implicitly defined as deleted
                        /wd5027 # move assignment operator was implicitly defined as deleted
                        /wd5045 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
                        /wd5204 # class has virtual functions, but its trivial destructor is not virtual; instances of this class may not be destructed correctly
                        /wd5219 # implicit conversion from `xxx` to `yyy`, possible loss of data
                        /we4715
                        /Zc:wchar_t /Zc:__cplusplus /Zi)
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
    if(${CMAKE_BUILD_TYPE} STREQUAL Debug OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
        add_compile_options(-g3)
    endif()
    add_compile_options(-Wextra -Werror=return-type)
endif()

if(WIN32 AND MINGW)
    add_compile_options(-Wno-template-body)
endif()

set(WIN32_NATIVE_SOURCES
    rc/YADAW.rc
    # https://cmake.org/cmake/help/v3.4/release/3.4.html#other
    rc/YADAW.exe.manifest
    src/audio/backend/AudioGraphBackend.hpp
    src/audio/backend/AudioGraphBusConfiguration.cpp
    src/audio/backend/AudioGraphBusConfiguration.hpp
    src/audio/backend/WASAPIExclusiveBackend.hpp
    src/controller/AudioGraphBackendController.cpp
    src/controller/AudioGraphBackendController.hpp
    src/model/AudioGraphInputDeviceListModel.cpp
    src/model/AudioGraphInputDeviceListModel.hpp
    src/model/AudioGraphOutputDeviceListModel.cpp
    src/model/AudioGraphOutputDeviceListModel.hpp
    src/native/win/AudioEngineWorkerThreadScheduler.cpp
    src/native/win/AudioGraphBackend.cpp
    src/native/win/AudioGraphBackendImpl.cpp
    src/native/win/AudioGraphBackendImpl.hpp
    src/native/win/CLAPNative.cpp
    src/native/win/CPU.cpp
    src/native/win/InterProcessMutexImpl.cpp
    src/native/win/InterProcessMutexImpl.hpp
    src/native/win/InterProcessMutex.cpp
    src/native/win/Library.cpp
    src/native/win/Library.cpp
    src/native/win/MIDIInputDeviceImpl.cpp
    src/native/win/MIDIInputDeviceImpl.hpp
    src/native/win/MIDIOutputDeviceImpl.cpp
    src/native/win/MIDIOutputDeviceImpl.hpp
    src/native/win/MMCSSThreadTaskAssociator.cpp
    src/native/win/MMCSSThreadTaskAssociator.hpp
    src/native/win/Native.cpp
    src/native/win/Shell.cpp
    src/native/win/Thread.cpp
    src/native/win/VST3Native.cpp
    src/native/win/VestifalNative.cpp
    src/native/win/WASAPIExclusiveBackend.cpp
    src/native/win/WASAPIExclusiveBackendImpl.cpp
    src/native/win/WASAPIExclusiveBackendImpl.hpp
    src/native/win/Window.cpp
    src/native/win/winrt/Async.hpp
    src/native/win/winrt/Forward.hpp
    src/native/win/winrt/QStringFromHString.cpp
    src/native/win/winrt/QStringFromHString.hpp
)

set(MAC_NATIVE_SOURCES
    src/audio/backend/CoreAudioBackend.hpp
    src/audio/backend/CoreAudioBusConfiguration.cpp
    src/audio/backend/CoreAudioBusConfiguration.hpp
    src/audio/plugin/AudioUnitV3Plugin.cpp
    src/audio/plugin/AudioUnitV3Plugin.hpp
    src/controller/CoreAudioBackendController.cpp
    src/controller/CoreAudioBackendController.hpp
    src/native/mac/AudioEngineWorkerThreadScheduler.cpp
    src/native/mac/CLAPNative.cpp
    src/native/mac/CPU.cpp
    src/native/mac/CoreAudioBackend.cpp
    src/native/mac/CoreAudioBackendImpl.cpp
    src/native/mac/CoreAudioBackendImpl.hpp
    src/native/mac/Library.cpp
    src/native/mac/MIDIInputDeviceImpl.cpp
    src/native/mac/MIDIInputDeviceImpl.hpp
    src/native/mac/MIDIOutputDeviceImpl.cpp
    src/native/mac/MIDIOutputDeviceImpl.hpp
    src/native/mac/Native.cpp
    src/native/mac/Shell.cpp
    src/native/mac/Thread.cpp
    src/native/mac/VST3Native.cpp
    src/native/mac/VestifalNative.cpp
    src/native/mac/Window.mm
)

set(LINUX_NATIVE_SOURCES
    src/audio/backend/ALSABackend.hpp
    src/audio/backend/ALSABusConfiguration.cpp
    src/audio/backend/ALSABusConfiguration.hpp
    src/audio/backend/ALSADeviceSelector.hpp
    src/controller/ALSABackendController.cpp
    src/controller/ALSABackendController.hpp
    src/model/ALSAInputDeviceListModel.cpp
    src/model/ALSAInputDeviceListModel.hpp
    src/model/ALSAOutputDeviceListModel.cpp
    src/model/ALSAOutputDeviceListModel.hpp
    src/native/linux/ALSABackend.cpp
    src/native/linux/ALSABackendImpl.cpp
    src/native/linux/ALSABackendImpl.hpp
    src/native/linux/ALSADeviceEnumerator.cpp
    src/native/linux/ALSADeviceEnumerator.hpp
    src/native/linux/ALSAHelper.hpp
    src/native/linux/AudioEngineWorkerThreadScheduler.cpp
    src/native/linux/CLAPNative.cpp
    src/native/linux/CPU.cpp
    src/native/linux/Library.cpp
    src/native/linux/MIDIInputDeviceImpl.cpp
    src/native/linux/MIDIInputDeviceImpl.hpp
    src/native/linux/MIDIOutputDeviceImpl.cpp
    src/native/linux/MIDIOutputDeviceImpl.hpp
    src/native/linux/Native.cpp
    src/native/linux/Sequencer.cpp
    src/native/linux/Sequencer.hpp
    src/native/linux/Shell.cpp
    src/native/linux/Thread.cpp
    src/native/linux/VST3Native.cpp
    src/native/linux/VestifalNative.cpp
    src/native/linux/Window.cpp
)

if(WIN32)
    set(NATIVE_SOURCES ${WIN32_NATIVE_SOURCES})
elseif(APPLE)
    set(NATIVE_SOURCES ${MAC_NATIVE_SOURCES})
elseif(LINUX)
    set(NATIVE_SOURCES ${LINUX_NATIVE_SOURCES})
endif()

set(YADAW_COMMON_SOURCES
    ${NATIVE_SOURCES}
    src/audio/backend/ALSAErrorText.cpp
    src/audio/backend/ALSAErrorText.hpp
    src/audio/backend/AudioBackendBase.hpp
    src/audio/backend/AudioBackendSupport.hpp
    src/audio/backend/AudioGraphErrorText.cpp
    src/audio/backend/AudioGraphErrorText.hpp
    src/audio/base/Automation.cpp
    src/audio/base/Automation.hpp
    src/audio/base/Channel.hpp
    src/audio/base/Gain.hpp
    src/audio/base/StereoPanning.hpp
    src/audio/base/TempoAutomation.hpp
    src/audio/base/TimeSignatureSequence.cpp
    src/audio/base/TimeSignatureSequence.hpp
    src/audio/device/IAudioBusConfiguration.hpp
    src/audio/device/IAudioChannelGroup.cpp
    src/audio/device/IAudioChannelGroup.hpp
    src/audio/device/IAudioDevice.hpp
    src/audio/engine/AudioDeviceGraph.hpp
    src/audio/engine/AudioDeviceGraphBase.cpp
    src/audio/engine/AudioDeviceGraphBase.hpp
    src/audio/engine/AudioDeviceGraphProcess.cpp
    src/audio/engine/AudioDeviceGraphProcess.hpp
    src/audio/engine/AudioDeviceGraphWithPDC.cpp
    src/audio/engine/AudioDeviceGraphWithPDC.hpp
    src/audio/engine/AudioDeviceProcess.hpp
    src/audio/engine/AudioEngineWorkerThreadPool.cpp
    src/audio/engine/AudioEngineWorkerThreadPool.hpp
    src/audio/engine/AudioProcessDataBufferContainer.hpp
    src/audio/engine/MultiInputDeviceWithPDC.cpp
    src/audio/engine/MultiInputDeviceWithPDC.hpp
    src/audio/engine/extension/Buffer.cpp
    src/audio/engine/extension/Buffer.hpp
    src/audio/engine/extension/NameTag.cpp
    src/audio/engine/extension/NameTag.hpp
    src/audio/engine/extension/UpstreamLatency.cpp
    src/audio/engine/extension/UpstreamLatency.hpp
    src/audio/event/IEventBusInfo.hpp
    src/audio/event/IEventProcessor.hpp
    src/audio/host/CLAPEventList.cpp
    src/audio/host/CLAPEventList.hpp
    src/audio/host/CLAPHost.cpp
    src/audio/host/CLAPHost.hpp
    src/audio/host/CLAPTimerSupport.cpp
    src/audio/host/CLAPTimerSupport.hpp
    src/audio/host/EventFileDescriptorSupport.cpp
    src/audio/host/EventFileDescriptorSupport.hpp
    src/audio/host/HostContext.cpp
    src/audio/host/HostContext.hpp
    src/audio/host/VST3AttributeList.cpp
    src/audio/host/VST3AttributeList.hpp
    src/audio/host/VST3ComponentHandler.cpp
    src/audio/host/VST3ComponentHandler.hpp
    src/audio/host/VST3EventDoubleBuffer.cpp
    src/audio/host/VST3EventDoubleBuffer.hpp
    src/audio/host/VST3EventList.cpp
    src/audio/host/VST3EventList.hpp
    src/audio/host/VST3Host.cpp
    src/audio/host/VST3Host.hpp
    src/audio/host/VST3Message.cpp
    src/audio/host/VST3Message.hpp
    src/audio/host/VST3ParameterChanges.cpp
    src/audio/host/VST3ParameterChanges.hpp
    src/audio/host/VST3ParameterValueQueue.cpp
    src/audio/host/VST3ParameterValueQueue.hpp
    src/audio/host/VST3PlugFrame.cpp
    src/audio/host/VST3PlugFrame.hpp
    src/audio/host/VST3RunLoop.cpp
    src/audio/host/VST3RunLoop.hpp
    src/audio/host/VestifalCallback.cpp
    src/audio/host/VestifalCallback.hpp
    src/audio/mixer/BlankGenerator.cpp
    src/audio/mixer/BlankGenerator.hpp
    src/audio/mixer/BlankReceiver.cpp
    src/audio/mixer/BlankReceiver.hpp
    src/audio/mixer/Common.hpp
    src/audio/mixer/Inserts.cpp
    src/audio/mixer/Inserts.hpp
    src/audio/mixer/Meter.cpp
    src/audio/mixer/Meter.hpp
    src/audio/mixer/Mixer.cpp
    src/audio/mixer/Mixer.hpp
    src/audio/mixer/PolarityInverter.cpp
    src/audio/mixer/PolarityInverter.hpp
    src/audio/mixer/VolumeFader.cpp
    src/audio/mixer/VolumeFader.hpp
    src/audio/plugin/AudioPluginBase.hpp
    src/audio/plugin/CLAPAudioChannelGroup.cpp
    src/audio/plugin/CLAPAudioChannelGroup.hpp
    src/audio/plugin/CLAPEventBusInfo.cpp
    src/audio/plugin/CLAPEventBusInfo.hpp
    src/audio/plugin/CLAPEventProcessor.cpp
    src/audio/plugin/CLAPEventProcessor.hpp
    src/audio/plugin/CLAPPlugin.cpp
    src/audio/plugin/CLAPPlugin.hpp
    src/audio/plugin/CLAPPluginGUI.cpp
    src/audio/plugin/CLAPPluginGUI.hpp
    src/audio/plugin/CLAPPluginParameter.cpp
    src/audio/plugin/CLAPPluginParameter.hpp
    src/audio/plugin/IAudioPlugin.hpp
    src/audio/device/IParameter.hpp
    src/audio/plugin/IPluginGUI.hpp
    src/audio/device/IAudioDeviceParameter.hpp
    src/audio/plugin/PluginFormatSupport.hpp
    src/audio/plugin/PluginText.cpp
    src/audio/plugin/PluginText.hpp
    src/audio/plugin/VST3AudioChannelGroup.cpp
    src/audio/plugin/VST3AudioChannelGroup.hpp
    src/audio/plugin/VST3EventBusInfo.cpp
    src/audio/plugin/VST3EventBusInfo.hpp
    src/audio/plugin/VST3EventProcessor.cpp
    src/audio/plugin/VST3EventProcessor.hpp
    src/audio/plugin/VST3MemoryStream.cpp
    src/audio/plugin/VST3Plugin.cpp
    src/audio/plugin/VST3Plugin.hpp
    src/audio/plugin/VST3PluginGUI.cpp
    src/audio/plugin/VST3PluginGUI.hpp
    src/audio/plugin/VST3PluginParameter.cpp
    src/audio/plugin/VST3PluginParameter.hpp
    src/audio/plugin/VestifalPlugin.cpp
    src/audio/plugin/VestifalPlugin.cpp
    src/audio/plugin/VestifalPlugin.hpp
    src/audio/plugin/VestifalPlugin.hpp
    src/audio/plugin/VestifalPluginGUI.cpp
    src/audio/plugin/VestifalPluginGUI.hpp
    src/audio/plugin/VestifalPluginParameter.cpp
    src/audio/plugin/VestifalPluginParameter.hpp
    src/audio/util/AudioBufferPool.cpp
    src/audio/util/AudioBufferPool.hpp
    src/audio/util/AudioChannelGroup.cpp
    src/audio/util/AudioChannelGroup.hpp
    src/audio/util/AudioDeviceUtil.cpp
    src/audio/util/AudioDeviceUtil.hpp
    src/audio/util/AudioProcessDataPointerContainer.hpp
    src/audio/util/CLAPHelper.cpp
    src/audio/util/CLAPHelper.hpp
    src/audio/util/ChannelGroupRemixer.cpp
    src/audio/util/ChannelGroupRemixer.hpp
    src/audio/util/InputSwitcher.cpp
    src/audio/util/InputSwitcher.hpp
    src/audio/util/Mute.cpp
    src/audio/util/Mute.hpp
    src/audio/util/SampleDelay.cpp
    src/audio/util/SampleDelay.hpp
    src/audio/util/Splitter.cpp
    src/audio/util/Splitter.hpp
    src/audio/util/SquareSum.hpp
    src/audio/util/Summing.cpp
    src/audio/util/Summing.hpp
    src/audio/util/VST3Helper.cpp
    src/audio/util/VST3Helper.hpp
    src/audio/util/VestifalHelper.cpp
    src/audio/util/VestifalHelper.hpp
    src/base/Constants.hpp
    src/concurrent/AtomicMutex.cpp
    src/concurrent/AtomicMutex.hpp
    src/concurrent/DoubleBufferSwitch.hpp
    src/concurrent/InterProcessMutex.hpp
    src/concurrent/FixedSizeLockFreeQueue.hpp
    src/concurrent/PassDataToRealtimeThread.hpp
    src/controller/AppController.cpp
    src/controller/AppController.hpp
    src/controller/AssetDirectoryController.cpp
    src/controller/AssetDirectoryController.hpp
    src/controller/AudioBackendController.cpp
    src/controller/AudioBackendController.hpp
    src/controller/AudioBusConfigurationController.cpp
    src/controller/AudioBusConfigurationController.hpp
    src/controller/AudioEngineController.cpp
    src/controller/AudioEngineController.hpp
    src/controller/CLAPPluginPool.cpp
    src/controller/CLAPPluginPool.hpp
    src/controller/ConfigController.cpp
    src/controller/ConfigController.hpp
    src/controller/DatabaseController.cpp
    src/controller/DatabaseController.hpp
    src/controller/GeneralSettingsController.cpp
    src/controller/GeneralSettingsController.hpp
    src/controller/LibraryPluginMap.cpp
    src/controller/LibraryPluginMap.hpp
    src/controller/LibraryPluginPool.cpp
    src/controller/LibraryPluginPool.hpp
    src/controller/LocalizationController.cpp
    src/controller/LocalizationController.hpp
    src/controller/MixerChannelListModelController.cpp
    src/controller/MixerChannelListModelController.hpp
    src/controller/PluginContext.cpp
    src/controller/PluginContext.hpp
    src/controller/PluginController.cpp
    src/controller/PluginController.hpp
    src/controller/PluginDirectoryController.cpp
    src/controller/PluginDirectoryController.hpp
    src/controller/PluginIOConfigUpdatedCallback.cpp
    src/controller/PluginIOConfigUpdatedCallback.hpp
    src/controller/PluginLatencyUpdatedCallback.cpp
    src/controller/PluginLatencyUpdatedCallback.hpp
    src/controller/PluginListController.cpp
    src/controller/PluginListController.hpp
    src/controller/PluginPositionMap.hpp
    src/controller/PluginWindowController.cpp
    src/controller/PluginWindowController.hpp
    src/controller/VST3PluginPool.cpp
    src/controller/VST3PluginPool.hpp
    src/dao/AssetDirectoryTable.cpp
    src/dao/AssetDirectoryTable.hpp
    src/dao/Config.cpp
    src/dao/Config.hpp
    src/dao/DAOBase.cpp
    src/dao/DAOBase.hpp
    src/dao/Database.cpp
    src/dao/Database.hpp
    src/dao/Logging.cpp
    src/dao/Logging.hpp
    src/dao/PluginCategoryTable.cpp
    src/dao/PluginCategoryTable.hpp
    src/dao/PluginDirectoryTable.cpp
    src/dao/PluginDirectoryTable.hpp
    src/dao/PluginLibraryTable.cpp
    src/dao/PluginLibraryTable.hpp
    src/dao/PluginTable.cpp
    src/dao/PluginTable.hpp
    src/entity/AudioBackendSupport.cpp
    src/entity/ChannelConfig.cpp
    src/entity/ChannelConfigHelper.cpp
    src/entity/ChannelConfigHelper.hpp
    src/entity/EntityInitializer.cpp
    src/entity/EntityInitializer.hpp
    src/entity/HardwareAudioIOPosition.cpp
    src/entity/HardwareAudioIOPosition.hpp
    src/entity/PluginAuxAudioIOPosition.cpp
    src/entity/PluginAuxAudioIOPosition.hpp
    src/entity/PluginFormatSupport.cpp
    src/entity/RegularAudioIOPosition.cpp
    src/entity/RegularAudioIOPosition.hpp
    src/entity/SendPosition.cpp
    src/entity/SendPosition.hpp
    src/event/EventBase.cpp
    src/event/EventBase.hpp
    src/event/EventHandler.cpp
    src/event/EventHandler.hpp
    src/event/SplashScreenWorkerThread.cpp
    src/event/SplashScreenWorkerThread.hpp
    src/l10n/L10N.cpp
    src/l10n/L10N.hpp
    src/midi/DeviceInfo.hpp
    src/midi/MIDIInputDevice.cpp
    src/midi/MIDIInputDevice.hpp
    src/midi/MIDIOutputDevice.hpp
    src/midi/MIDIOutputDevice.cpp
    src/midi/Message.hpp
    src/midi/MessageToCLAPEvent.cpp
    src/midi/MessageToCLAPEvent.hpp
    src/midi/MessageToVST3Event.cpp
    src/midi/MessageToVST3Event.hpp
    src/model/AssetDirectoryListModel.cpp
    src/model/AssetDirectoryListModel.hpp
    src/model/AudioBusChannelListModel.cpp
    src/model/AudioBusChannelListModel.hpp
    src/model/AudioBusConfigurationModel.cpp
    src/model/AudioBusConfigurationModel.hpp
    src/model/AudioDeviceIOGroupListModel.cpp
    src/model/AudioDeviceIOGroupListModel.hpp
    src/model/AutomationModel.cpp
    src/model/AutomationModel.hpp
    src/model/AuxIOTargetListModel.cpp
    src/model/AuxIOTargetListModel.hpp
    src/model/AuxInputSourceListModel.cpp
    src/model/AuxInputSourceListModel.hpp
    src/model/AuxOutputDestinationListModel.cpp
    src/model/AuxOutputDestinationListModel.hpp
    src/model/AuxOutputDestinationModel.cpp
    src/model/AuxOutputDestinationModel.hpp
    src/model/CLAPAudioBusConfigurationListModel.cpp
    src/model/CLAPAudioBusConfigurationListModel.hpp
    src/model/FileTreeModel.cpp
    src/model/FileTreeModel.hpp
    src/model/FilterRoleModel.cpp
    src/model/HardwareAudioIOPositionModel.cpp
    src/model/HardwareAudioIOPositionModel.hpp
    src/model/LocalizationListModel.cpp
    src/model/LocalizationListModel.hpp
    src/model/MessageDialogButtonBoxModel.cpp
    src/model/MixerAudioIOPositionItemModel.cpp
    src/model/MixerAudioIOPositionItemModel.hpp
    src/model/MixerChannelInsertListModel.cpp
    src/model/MixerChannelInsertListModel.hpp
    src/model/MixerChannelListModel.cpp
    src/model/MixerChannelListModel.hpp
    src/model/MixerChannelSendListModel.cpp
    src/model/MixerChannelSendListModel.hpp
    src/model/ModelInitializer.cpp
    src/model/ModelInitializer.hpp
    src/model/ParameterValueAndTextListModel.cpp
    src/model/ParameterValueAndTextListModel.hpp
    src/model/PluginCategoryListModel.cpp
    src/model/PluginCategoryListModel.hpp
    src/model/PluginContextUserData.cpp
    src/model/PluginContextUserData.hpp
    src/model/PluginDirectoryListModel.cpp
    src/model/PluginDirectoryListModel.hpp
    src/model/PluginListModel.cpp
    src/model/PluginListModel.hpp
    src/model/PluginParameterListModel.cpp
    src/model/PluginParameterListModel.hpp
    src/model/PolarityInverterModel.cpp
    src/model/PolarityInverterModel.hpp
    src/model/QuickMenuEventFilterModel.cpp
    src/model/QuickMenuEventFilterModel.hpp
    src/model/RegularAudioIOPositionModel.cpp
    src/model/RegularAudioIOPositionModel.hpp
    src/model/SortOrderModel.cpp
    src/model/SortFilterProxyListModel.cpp
    src/model/SpeakerListModel.cpp
    src/model/SpeakerListModel.hpp
    src/model/TreeModelToListModel.cpp
    src/model/impl/TreeNode.hpp
    src/native/AudioBackendSupport.hpp
    src/native/AudioEngineWorkerThreadScheduler.hpp
    src/native/CLAPNative.hpp
    src/native/CPU.hpp
    src/native/Library.hpp
    src/native/MIDIDeviceID.hpp
    src/native/MIDIInputDeviceImpl.hpp
    src/native/MIDIOutputDeviceImpl.hpp
    src/native/Native.hpp
    src/native/PluginFormatSupport.hpp
    src/native/Shell.hpp
    src/native/Thread.hpp
    src/native/VST3Native.hpp
    src/native/VestifalNative.hpp
    src/native/Window.hpp
    src/ui/ExposeAndPaintEventFilter.cpp
    src/ui/ExposeAndPaintEventFilter.hpp
    src/ui/MessageDialog.cpp
    src/ui/MessageDialog.hpp
    src/ui/QuickMenuEventFilter.cpp
    src/ui/QuickMenuEventFilter.hpp
    src/ui/RawMouseEventFilter.cpp
    src/ui/RawMouseEventFilter.hpp
    src/ui/ResizeEventFilter.cpp
    src/ui/ResizeEventFilter.hpp
    src/ui/Runtime.cpp
    src/ui/Runtime.hpp
    src/ui/UI.cpp
    src/ui/UI.hpp
    src/ui/WindowAndId.hpp
    src/ui/WindowAndConnection.hpp
    src/util/ADEUtil.cpp
    src/util/ADEUtil.hpp
    src/util/Algorithm.hpp
    src/util/AlignHelper.hpp
    src/util/ArrayAccess.hpp
    src/util/AutoIncrementID.cpp
    src/util/AutoIncrementID.hpp
    src/util/Base.hpp
    src/util/BatchUpdater.cpp
    src/util/BatchUpdater.hpp
    src/util/ButlerThread.cpp
    src/util/ButlerThread.hpp
    src/util/CDeleter.hpp
    src/util/CircularDeque.hpp
    src/util/CompilerSpecifics.hpp
    src/util/Concepts.hpp
    src/util/Constants.hpp
    src/util/Endian.hpp
    src/util/FibonacciIterator.hpp
    src/util/FixedSizeCircularDeque.hpp
    src/util/FixedSizeLockFreeQueue.hpp
    src/util/FixedSizeMemoryBlock.hpp
    src/util/IntegerRange.hpp
    src/util/Integration.cpp
    src/util/Integration.hpp
    src/util/IntrusivePointer.hpp
    src/util/IntrusiveRefCounter.cpp
    src/util/IntrusiveRefCounter.hpp
    src/util/Literal.hpp
    src/util/LockFreeQueue.hpp
    src/util/OptionalUtil.hpp
    src/util/PolymorphicDeleter.hpp
    src/util/QStringUtil.hpp
    src/util/QmlUtil.hpp
    src/util/QuadraticFunction.cpp
    src/util/QuadraticFunction.hpp
    src/util/SampleFormat.hpp
    src/util/SineFunction.cpp
    src/util/SineFunction.hpp
    src/util/Stopwatch.hpp
    src/util/Util.cpp
    src/util/Util.hpp
    src/util/VectorTypes.hpp
    src/util/VectorUtil.hpp
    src/util/YAMLCppUtil.hpp
    src/util/ZeckendorfLogarithm.hpp
)

qt_add_executable(YADAW
                  src/main.cpp
                  ${YADAW_COMMON_SOURCES}
                  )

add_executable(CLAPTest
               src/audio/host/CLAPEventList.cpp
               src/audio/host/CLAPEventList.hpp
               src/audio/host/CLAPHost.cpp
               src/audio/host/CLAPHost.hpp
               src/audio/host/CLAPTimerSupport.hpp
               src/audio/host/CLAPTimerSupport.cpp
               src/audio/host/EventFileDescriptorSupport.cpp
               src/audio/host/EventFileDescriptorSupport.hpp
               src/audio/host/HostContext.cpp
               src/audio/host/HostContext.hpp
               src/audio/plugin/CLAPAudioChannelGroup.cpp
               src/audio/plugin/CLAPAudioChannelGroup.hpp
               src/audio/plugin/CLAPEventBusInfo.cpp
               src/audio/plugin/CLAPEventBusInfo.hpp
               src/audio/plugin/CLAPEventProcessor.cpp
               src/audio/plugin/CLAPEventProcessor.hpp
               src/audio/plugin/CLAPPlugin.cpp
               src/audio/plugin/CLAPPlugin.hpp
               src/audio/plugin/CLAPPluginGUI.cpp
               src/audio/plugin/CLAPPluginGUI.hpp
               src/audio/plugin/CLAPPluginParameter.cpp
               src/audio/plugin/CLAPPluginParameter.hpp
               src/audio/util/CLAPHelper.cpp
               src/audio/util/CLAPHelper.hpp
               src/native/CLAPNative.hpp
               src/native/linux/CLAPNative.cpp
               src/native/win/CLAPNative.cpp
               src/dao/DAOBase.cpp
               src/dao/DAOBase.hpp
               src/dao/Database.cpp
               src/dao/Database.hpp
               src/dao/PluginCategoryTable.cpp
               src/dao/PluginCategoryTable.hpp
               src/dao/PluginTable.cpp
               src/dao/PluginTable.hpp
               src/native/Library.hpp
               src/native/Native.hpp
               src/native/linux/CLAPNative.cpp
               src/native/linux/Library.cpp
               src/native/linux/Native.cpp
               src/native/linux/Window.cpp
               src/native/mac/CLAPNative.cpp
               src/native/mac/Library.cpp
               src/native/mac/Native.cpp
               src/native/mac/Window.mm
               src/native/win/CLAPNative.cpp
               src/native/win/Library.cpp
               src/native/win/Native.cpp
               src/native/win/Window.cpp
               src/ui/UI.cpp
               src/ui/UI.hpp
               src/ui/Runtime.cpp
               src/ui/Runtime.hpp
               src/util/Util.cpp
               src/util/Util.hpp
               test/common/CloseWindowEventFilter.cpp
               test/common/CloseWindowEventFilter.hpp
               test/CLAPTest/main.cpp
)

# Do this so since `EventFileDescriptorSupport` supports both VST3 and CLAP
# but we don't actually use VST3 support
target_include_directories(CLAPTest PRIVATE ${VST3SDK_SOURCE_DIR})

add_executable(MIDIInputDeviceTest
               src/midi/MIDIInputDevice.cpp
               src/midi/MIDIInputDevice.hpp
               src/midi/Message.hpp
               src/native/linux/ALSADeviceEnumerator.cpp
               src/native/linux/ALSADeviceEnumerator.hpp
               src/native/linux/MIDIInputDeviceImpl.cpp
               src/native/linux/MIDIInputDeviceImpl.hpp
               src/native/linux/Sequencer.cpp
               src/native/linux/Sequencer.hpp
               src/native/MIDIInputDeviceImpl.hpp
               src/native/win/MIDIInputDeviceImpl.cpp
               src/native/win/MIDIInputDeviceImpl.hpp
               src/native/win/winrt/QStringFromHString.cpp
               src/native/win/winrt/QStringFromHString.hpp
               src/util/Literal.hpp
               src/util/Util.cpp
               src/util/Util.hpp
               test/common/MIDICallback.cpp
               test/common/MIDICallback.hpp
               test/MIDIInputDeviceTest/main.cpp)

add_executable(PluginDirectoryScanTest
               src/audio/base/Automation.cpp
               src/audio/base/Automation.hpp
               src/audio/host/CLAPHost.cpp
               src/audio/host/CLAPHost.hpp
               src/audio/host/CLAPTimerSupport.cpp
               src/audio/host/CLAPTimerSupport.hpp
               src/audio/host/EventFileDescriptorSupport.cpp
               src/audio/host/EventFileDescriptorSupport.hpp
               src/audio/host/HostContext.cpp
               src/audio/host/HostContext.hpp
               src/audio/host/VST3AttributeList.cpp
               src/audio/host/VST3AttributeList.hpp
               src/audio/host/VST3ComponentHandler.cpp
               src/audio/host/VST3ComponentHandler.hpp
               src/audio/host/VST3Host.cpp
               src/audio/host/VST3Host.hpp
               src/audio/host/VST3Message.cpp
               src/audio/host/VST3Message.hpp
               src/audio/host/VST3ParameterChanges.cpp
               src/audio/host/VST3ParameterChanges.hpp
               src/audio/host/VST3ParameterValueQueue.cpp
               src/audio/host/VST3ParameterValueQueue.hpp
               src/audio/host/VST3PlugFrame.cpp
               src/audio/host/VST3PlugFrame.hpp
               src/audio/host/VST3RunLoop.cpp
               src/audio/host/VST3RunLoop.hpp
               src/audio/host/VestifalCallback.cpp
               src/audio/host/VestifalCallback.hpp
               src/audio/plugin/CLAPAudioChannelGroup.cpp
               src/audio/plugin/CLAPAudioChannelGroup.hpp
               src/audio/plugin/CLAPEventBusInfo.cpp
               src/audio/plugin/CLAPEventBusInfo.hpp
               src/audio/plugin/CLAPEventProcessor.cpp
               src/audio/plugin/CLAPEventProcessor.hpp
               src/audio/plugin/CLAPPlugin.cpp
               src/audio/plugin/CLAPPlugin.hpp
               src/audio/plugin/CLAPPluginGUI.cpp
               src/audio/plugin/CLAPPluginGUI.hpp
               src/audio/plugin/CLAPPluginParameter.cpp
               src/audio/plugin/CLAPPluginParameter.hpp
               src/audio/plugin/VST3AudioChannelGroup.cpp
               src/audio/plugin/VST3AudioChannelGroup.hpp
               src/audio/plugin/VST3EventBusInfo.cpp
               src/audio/plugin/VST3EventBusInfo.hpp
               src/audio/plugin/VST3EventProcessor.cpp
               src/audio/plugin/VST3EventProcessor.hpp
               src/audio/plugin/VST3MemoryStream.cpp
               src/audio/plugin/VST3Plugin.cpp
               src/audio/plugin/VST3Plugin.hpp
               src/audio/plugin/VST3PluginGUI.cpp
               src/audio/plugin/VST3PluginGUI.hpp
               src/audio/plugin/VST3PluginParameter.cpp
               src/audio/plugin/VST3PluginParameter.hpp
               src/audio/plugin/VestifalPlugin.cpp
               src/audio/plugin/VestifalPlugin.hpp
               src/audio/plugin/VestifalPluginGUI.cpp
               src/audio/plugin/VestifalPluginGUI.hpp
               src/audio/plugin/VestifalPluginParameter.cpp
               src/audio/plugin/VestifalPluginParameter.hpp
               src/audio/util/CLAPHelper.cpp
               src/audio/util/CLAPHelper.hpp
               src/audio/util/VST3Helper.cpp
               src/audio/util/VST3Helper.hpp
               src/audio/util/VestifalHelper.cpp
               src/audio/util/VestifalHelper.hpp
               src/concurrent/AtomicMutex.cpp
               src/concurrent/AtomicMutex.hpp
               src/controller/LibraryPluginMap.cpp
               src/controller/LibraryPluginMap.hpp
               src/controller/PluginController.cpp
               src/controller/PluginController.hpp
               src/dao/DAOBase.cpp
               src/dao/DAOBase.hpp
               src/dao/Database.cpp
               src/dao/Database.hpp
               src/dao/PluginCategoryTable.cpp
               src/dao/PluginCategoryTable.hpp
               src/dao/PluginTable.cpp
               src/dao/PluginTable.hpp
               src/native/CLAPNative.hpp
               src/native/Library.hpp
               src/native/Native.hpp
               src/native/VST3Native.hpp
               src/native/VestifalNative.hpp
               src/native/linux/CLAPNative.cpp
               src/native/linux/Library.cpp
               src/native/linux/Native.cpp
               src/native/linux/VST3Native.cpp
               src/native/linux/VestifalNative.cpp
               src/native/mac/Library.cpp
               src/native/mac/Native.cpp
               src/native/mac/CLAPNative.cpp
               src/native/mac/VST3Native.cpp
               src/native/mac/VestifalNative.cpp
               src/native/win/CLAPNative.cpp
               src/native/win/Library.cpp
               src/native/win/Native.cpp
               src/native/win/VST3Native.cpp
               src/native/win/VestifalNative.cpp
               src/util/QuadraticFunction.cpp
               src/util/QuadraticFunction.hpp
               src/util/Util.cpp
               src/util/Util.hpp
               test/PluginDirectoryScanTest/main.cpp)

add_executable(PluginScanTest
               src/audio/base/Automation.cpp
               src/audio/base/Automation.hpp
               src/audio/host/CLAPHost.cpp
               src/audio/host/CLAPHost.hpp
               src/audio/host/CLAPTimerSupport.cpp
               src/audio/host/CLAPTimerSupport.hpp
               src/audio/host/EventFileDescriptorSupport.cpp
               src/audio/host/EventFileDescriptorSupport.hpp
               src/audio/host/HostContext.cpp
               src/audio/host/HostContext.hpp
               src/audio/host/VST3AttributeList.cpp
               src/audio/host/VST3AttributeList.hpp
               src/audio/host/VST3ComponentHandler.cpp
               src/audio/host/VST3ComponentHandler.hpp
               src/audio/host/VST3Host.cpp
               src/audio/host/VST3Host.hpp
               src/audio/host/VST3Message.cpp
               src/audio/host/VST3Message.hpp
               src/audio/host/VST3ParameterChanges.cpp
               src/audio/host/VST3ParameterChanges.hpp
               src/audio/host/VST3ParameterValueQueue.cpp
               src/audio/host/VST3ParameterValueQueue.hpp
               src/audio/host/VST3PlugFrame.cpp
               src/audio/host/VST3PlugFrame.hpp
               src/audio/host/VST3RunLoop.cpp
               src/audio/host/VST3RunLoop.hpp
               src/audio/host/VestifalCallback.cpp
               src/audio/host/VestifalCallback.hpp
               src/audio/plugin/CLAPAudioChannelGroup.cpp
               src/audio/plugin/CLAPAudioChannelGroup.hpp
               src/audio/plugin/CLAPEventBusInfo.cpp
               src/audio/plugin/CLAPEventBusInfo.hpp
               src/audio/plugin/CLAPEventProcessor.cpp
               src/audio/plugin/CLAPEventProcessor.hpp
               src/audio/plugin/CLAPPlugin.cpp
               src/audio/plugin/CLAPPlugin.hpp
               src/audio/plugin/CLAPPluginGUI.cpp
               src/audio/plugin/CLAPPluginGUI.hpp
               src/audio/plugin/CLAPPluginParameter.cpp
               src/audio/plugin/CLAPPluginParameter.hpp
               src/audio/plugin/VST3AudioChannelGroup.cpp
               src/audio/plugin/VST3AudioChannelGroup.hpp
               src/audio/plugin/VST3EventBusInfo.cpp
               src/audio/plugin/VST3EventBusInfo.hpp
               src/audio/plugin/VST3EventProcessor.cpp
               src/audio/plugin/VST3EventProcessor.hpp
               src/audio/plugin/VST3MemoryStream.cpp
               src/audio/plugin/VST3Plugin.cpp
               src/audio/plugin/VST3Plugin.hpp
               src/audio/plugin/VST3PluginGUI.cpp
               src/audio/plugin/VST3PluginGUI.hpp
               src/audio/plugin/VST3PluginParameter.cpp
               src/audio/plugin/VST3PluginParameter.hpp
               src/audio/plugin/VestifalPlugin.cpp
               src/audio/plugin/VestifalPlugin.hpp
               src/audio/plugin/VestifalPluginGUI.cpp
               src/audio/plugin/VestifalPluginGUI.hpp
               src/audio/plugin/VestifalPluginParameter.cpp
               src/audio/plugin/VestifalPluginParameter.hpp
               src/audio/util/CLAPHelper.cpp
               src/audio/util/CLAPHelper.hpp
               src/audio/util/VST3Helper.cpp
               src/audio/util/VST3Helper.hpp
               src/audio/util/VestifalHelper.cpp
               src/audio/util/VestifalHelper.hpp
               src/concurrent/AtomicMutex.cpp
               src/concurrent/AtomicMutex.hpp
               src/controller/LibraryPluginMap.cpp
               src/controller/LibraryPluginMap.hpp
               src/controller/PluginController.cpp
               src/controller/PluginController.hpp
               src/dao/DAOBase.cpp
               src/dao/DAOBase.hpp
               src/dao/Database.cpp
               src/dao/Database.hpp
               src/dao/PluginCategoryTable.cpp
               src/dao/PluginCategoryTable.hpp
               src/dao/PluginTable.cpp
               src/dao/PluginTable.hpp
               src/native/CLAPNative.hpp
               src/native/Library.hpp
               src/native/Native.hpp
               src/native/VST3Native.hpp
               src/native/VestifalNative.hpp
               src/native/linux/CLAPNative.cpp
               src/native/linux/Library.cpp
               src/native/linux/Native.cpp
               src/native/linux/VST3Native.cpp
               src/native/linux/VestifalNative.cpp
               src/native/mac/Library.cpp
               src/native/mac/Native.cpp
               src/native/mac/CLAPNative.cpp
               src/native/mac/VST3Native.cpp
               src/native/mac/VestifalNative.cpp
               src/native/win/CLAPNative.cpp
               src/native/win/Library.cpp
               src/native/win/Native.cpp
               src/native/win/VST3Native.cpp
               src/native/win/VestifalNative.cpp
               src/util/QuadraticFunction.cpp
               src/util/QuadraticFunction.hpp
               src/util/Util.cpp
               src/util/Util.hpp
               test/PluginScanTest/main.cpp)

add_executable(VestifalPluginTest
               src/audio/host/VestifalCallback.cpp
               src/audio/host/VestifalCallback.hpp
               src/audio/plugin/VestifalPlugin.cpp
               src/audio/plugin/VestifalPlugin.hpp
               src/audio/plugin/VestifalPluginGUI.cpp
               src/audio/plugin/VestifalPluginGUI.hpp
               src/audio/plugin/VestifalPluginParameter.cpp
               src/audio/plugin/VestifalPluginParameter.hpp
               src/audio/util/VestifalHelper.cpp
               src/audio/util/VestifalHelper.hpp
               src/dao/DAOBase.cpp
               src/dao/DAOBase.hpp
               src/dao/Database.cpp
               src/dao/Database.hpp
               src/dao/PluginCategoryTable.cpp
               src/dao/PluginCategoryTable.hpp
               src/dao/PluginTable.cpp
               src/dao/PluginTable.hpp
               src/native/Library.hpp
               src/native/Native.hpp
               src/native/VestifalNative.hpp
               src/native/linux/Library.cpp
               src/native/linux/Native.cpp
               src/native/linux/VestifalNative.cpp
               src/native/win/Library.cpp
               src/native/win/Native.cpp
               src/native/win/VestifalNative.cpp
               test/common/PluginWindowThread.hpp
               test/common/PluginWindowThread.cpp
               test/VestifalPluginTest/main.cpp)

add_executable(VST3Test
               src/audio/base/Automation.cpp
               src/audio/base/Automation.hpp
               src/audio/host/EventFileDescriptorSupport.cpp
               src/audio/host/EventFileDescriptorSupport.hpp
               src/audio/host/HostContext.cpp
               src/audio/host/HostContext.hpp
               src/audio/host/VST3AttributeList.cpp
               src/audio/host/VST3AttributeList.hpp
               src/audio/host/VST3ComponentHandler.cpp
               src/audio/host/VST3ComponentHandler.hpp
               src/audio/host/VST3EventDoubleBuffer.cpp
               src/audio/host/VST3EventDoubleBuffer.hpp
               src/audio/host/VST3EventList.cpp
               src/audio/host/VST3EventList.hpp
               src/audio/host/VST3Host.cpp
               src/audio/host/VST3Host.hpp
               src/audio/host/VST3Message.cpp
               src/audio/host/VST3Message.hpp
               src/audio/host/VST3ParameterChanges.cpp
               src/audio/host/VST3ParameterChanges.hpp
               src/audio/host/VST3ParameterValueQueue.cpp
               src/audio/host/VST3ParameterValueQueue.hpp
               src/audio/host/VST3PlugFrame.cpp
               src/audio/host/VST3PlugFrame.hpp
               src/audio/host/VST3RunLoop.cpp
               src/audio/host/VST3RunLoop.hpp
               src/audio/plugin/VST3AudioChannelGroup.cpp
               src/audio/plugin/VST3AudioChannelGroup.hpp
               src/audio/plugin/VST3EventBusInfo.cpp
               src/audio/plugin/VST3EventBusInfo.hpp
               src/audio/plugin/VST3EventProcessor.cpp
               src/audio/plugin/VST3EventProcessor.hpp
               src/audio/plugin/VST3MemoryStream.cpp
               src/audio/plugin/VST3Plugin.cpp
               src/audio/plugin/VST3Plugin.hpp
               src/audio/plugin/VST3PluginGUI.cpp
               src/audio/plugin/VST3PluginGUI.hpp
               src/audio/plugin/VST3PluginParameter.cpp
               src/audio/plugin/VST3PluginParameter.hpp
               src/audio/util/VST3Helper.cpp
               src/audio/util/VST3Helper.hpp
               src/concurrent/AtomicMutex.cpp
               src/concurrent/AtomicMutex.hpp
               src/dao/DAOBase.cpp
               src/dao/DAOBase.hpp
               src/dao/Database.cpp
               src/dao/Database.hpp
               src/dao/PluginCategoryTable.cpp
               src/dao/PluginCategoryTable.hpp
               src/dao/PluginTable.cpp
               src/dao/PluginTable.hpp
               src/midi/MIDIInputDevice.cpp
               src/midi/MIDIInputDevice.hpp
               src/midi/Message.hpp
               src/midi/MessageToVST3Event.cpp
               src/midi/MessageToVST3Event.hpp
               src/native/Library.hpp
               src/native/MIDIInputDeviceImpl.hpp
               src/native/Native.hpp
               src/native/VST3Native.hpp
               src/native/Window.hpp
               src/native/linux/ALSADeviceEnumerator.cpp
               src/native/linux/ALSADeviceEnumerator.hpp
               src/native/linux/ALSAHelper.hpp
               src/native/linux/Library.cpp
               src/native/linux/MIDIInputDeviceImpl.cpp
               src/native/linux/MIDIInputDeviceImpl.hpp
               src/native/linux/Native.cpp
               src/native/linux/Sequencer.cpp
               src/native/linux/Sequencer.hpp
               src/native/linux/VST3Native.cpp
               src/native/linux/Window.cpp
               src/native/mac/Library.cpp
               src/native/mac/Native.cpp
               src/native/mac/VST3Native.cpp
               src/native/mac/Window.mm
               src/native/win/Library.cpp
               src/native/win/MIDIInputDeviceImpl.cpp
               src/native/win/MIDIInputDeviceImpl.hpp
               src/native/win/Native.cpp
               src/native/win/VST3Native.cpp
               src/native/win/Window.cpp
               src/native/win/winrt/Async.hpp
               src/native/win/winrt/Forward.hpp
               src/native/win/winrt/QStringFromHString.cpp
               src/native/win/winrt/QStringFromHString.hpp
               src/ui/Runtime.cpp
               src/ui/Runtime.hpp
               src/ui/UI.cpp
               src/ui/UI.hpp
               src/util/QuadraticFunction.cpp
               src/util/QuadraticFunction.hpp
               src/util/Util.cpp
               src/util/Util.hpp
               test/common/CloseWindowEventFilter.cpp
               test/common/CloseWindowEventFilter.hpp
               test/VST3Test/main.cpp
)

if(${ENABLE_PRECOMPILE})
    target_precompile_headers(YADAW PRIVATE src/pch.hpp)
endif()

qt_add_qml_module(YADAW
                  URI "Main"
                  VERSION 1.0
                  NO_PLUGIN
                  QML_FILES Events.qml YADAW.qml)

if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL MinSizeRel)
    set_target_properties(YADAW PROPERTIES
        WIN32_EXECUTABLE TRUE
    )
endif()

if(WIN32)
    set(NATIVE_LIBRARY version ole32 user32 windowsapp avrt dwmapi)
    if(MINGW)
        set(NATIVE_LIBRARY ${NATIVE_LIBRARY}
            ksguid # KSDATAFORMAT_xxx
        )
    endif()
elseif(APPLE)
    set(NATIVE_LIBRARY
        "-framework CoreAudio"
        "-framework CoreFoundation")
elseif(LINUX)
    set(NATIVE_LIBRARY asound dl xcb xcb-icccm)
endif()

if(WIN32 AND MINGW)
    add_compile_options(-fcoroutines)
endif()

if(WIN32)
    if(DEFINED Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION)
        set(SQLITE_LIBRARY unofficial::sqlite3::sqlite3)
    else()
        set(SQLITE_LIBRARY sqlite3)
    endif()
elseif(APPLE)
    if(DEFINED Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION)
        set(SQLITE_LIBRARY unofficial::sqlite3::sqlite3)
    endif()
elseif(LINUX)
    set(SQLITE_LIBRARY sqlite3)
endif()

target_link_libraries(YADAW PRIVATE
                      Qt6::Core Qt6::Gui Qt6::Qml Qt6::Quick Qt6::QuickTemplates2
                      content
                      ade
                      ${NATIVE_LIBRARY}
                      base pluginterfaces sdk_common sdk_hosting
                      ${SQLITE_LIBRARY}
                      yaml-cpp::yaml-cpp)

set_target_properties(YADAW PROPERTIES
                      MACOSX_BUNDLE TRUE
                      MACOSX_BUNDLE_BUNDLE_NAME "YADAW"
                      MACOSX_BUNDLE_BUNDLE_COPYRIGHT "Copyright (c) 2023-2025 xris1658"
                      MACOSX_BUNDLE_GUI_IDENTIFIER "xris1658.yadaw"
                      MACOSX_BUNDLE_ICON_FILE "Main-icon.icns"
                      MACOSX_BUNDLE_INFO_STRING "Yet Another Digital Audio Workstation"
                      )

target_link_libraries(CLAPTest PRIVATE
                      Qt6::Core Qt6::Gui
                      ${NATIVE_LIBRARY}
                      ${SQLITE_LIBRARY})

target_link_libraries(PluginDirectoryScanTest PRIVATE
                      Qt6::Core Qt6::Gui
                      ${NATIVE_LIBRARY}
                      base pluginterfaces sdk_common sdk_hosting
                      ${SQLITE_LIBRARY})

target_link_libraries(PluginScanTest PRIVATE
                      Qt6::Core Qt6::Gui
                      ${NATIVE_LIBRARY}
                      base pluginterfaces sdk_common sdk_hosting
                      ${SQLITE_LIBRARY})

target_link_libraries(VestifalPluginTest PRIVATE
                      Qt6::Core Qt6::Gui
                      ${NATIVE_LIBRARY}
                      ${SQLITE_LIBRARY})

target_link_libraries(VST3Test PRIVATE
                      Qt6::Core Qt6::Gui
                      ${NATIVE_LIBRARY}
                      base pluginterfaces sdk_common sdk_hosting
                      ${SQLITE_LIBRARY})

if(MSVC)
    target_link_options(VST3Test PRIVATE /INCREMENTAL:NO /DEBUG)
endif()

if(WIN32)
target_link_libraries(MIDIInputDeviceTest PRIVATE
                      Qt6::Core
                      windowsapp)
elseif(LINUX)
target_link_libraries(MIDIInputDeviceTest PRIVATE
                      Qt6::Core
                      asound)
endif()

if(APPLE)
    set(RESOURCE_PATH ${CMAKE_CURRENT_BINARY_DIR}/YADAW.app/Contents/Resources)
else()
    set(RESOURCE_PATH ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_source_files_properties(l10n/osct/YADAW_zh_CN.ts
                            PROPERTIES
                            OUTPUT_LOCATION
                            ${RESOURCE_PATH}/l10n/osct)

qt_add_translations(YADAW TS_FILES l10n/osct/YADAW_zh_CN.ts
                    INCLUDE_DIRECTORIES ./src
                    SOURCE ${YADAW_COMMON_SOURCES})

file(COPY
     ./l10n/osct/YADAW_zh_CN.yml
     ./l10n/osct/wqy-microhei.ttc
     DESTINATION ${RESOURCE_PATH}/l10n/osct)

file(COPY
     ./rc/Main-icon.icns DESTINATION ${RESOURCE_PATH})

add_subdirectory(test)
